package com.cencat.merchant.entity;

import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 派单记录实体类
 * 
 * @author cencat
 * @since 2024
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("biz_dispatch_record")
public class DispatchRecordEntity {
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    
    /**
     * 租户ID
     */
    @NotNull(message = "租户ID不能为空")
    @TableField("tenant_id")
    private Long tenantId;
    
    /**
     * 订单ID
     */
    @NotNull(message = "订单ID不能为空")
    @TableField("order_id")
    private Long orderId;
    
    /**
     * 司机ID
     */
    @NotNull(message = "司机ID不能为空")
    @TableField("driver_id")
    private Long driverId;
    
    /**
     * 派单类型(0-自动,1-手动,2-指定)
     */
    @NotNull(message = "派单类型不能为空")
    @Min(value = 0, message = "派单类型值无效")
    @Max(value = 2, message = "派单类型值无效")
    @TableField("assign_type")
    private Integer assignType;
    
    /**
     * 派单时间
     */
    @NotNull(message = "派单时间不能为空")
    @TableField("assign_time")
    private LocalDateTime assignTime;
    
    /**
     * 优先级(1-最高,2-高,3-中,4-低,5-最低)
     */
    @NotNull(message = "优先级不能为空")
    @Min(value = 1, message = "优先级值无效")
    @Max(value = 5, message = "优先级值无效")
    @TableField("priority")
    private Integer priority;
    
    /**
     * 派单状态(0-待接单,1-已接单,2-已拒绝,3-已取消,4-已完成)
     */
    @NotNull(message = "派单状态不能为空")
    @Min(value = 0, message = "派单状态值无效")
    @Max(value = 4, message = "派单状态值无效")
    @TableField("dispatch_status")
    private Integer dispatchStatus;
    
    /**
     * 司机响应时间
     */
    @TableField("response_time")
    private LocalDateTime responseTime;
    
    /**
     * 匹配度分数(0-100)
     */
    @DecimalMin(value = "0.0", message = "匹配度分数不能为负数")
    @DecimalMax(value = "100.0", message = "匹配度分数不能超过100")
    @TableField("match_score")
    private BigDecimal matchScore;
    
    /**
     * 派单距离(公里)
     */
    @DecimalMin(value = "0.0", message = "派单距离不能为负数")
    @TableField("dispatch_distance")
    private BigDecimal dispatchDistance;
    
    /**
     * 预计送达时间
     */
    @TableField("estimated_arrival_time")
    private LocalDateTime estimatedArrivalTime;
    
    /**
     * 实际送达时间
     */
    @TableField("actual_arrival_time")
    private LocalDateTime actualArrivalTime;
    
    /**
     * 派单规则ID
     */
    @TableField("rule_id")
    private Long ruleId;
    
    /**
     * 派单算法类型(1-距离优先,2-评分优先,3-负载均衡,4-专属绑定)
     */
    @Min(value = 1, message = "派单算法类型值无效")
    @Max(value = 4, message = "派单算法类型值无效")
    @TableField("algorithm_type")
    private Integer algorithmType;
    
    /**
     * 拒绝原因
     */
    @Size(max = 200, message = "拒绝原因长度不能超过200个字符")
    @TableField("reject_reason")
    private String rejectReason;
    
    /**
     * 取消原因
     */
    @Size(max = 200, message = "取消原因长度不能超过200个字符")
    @TableField("cancel_reason")
    private String cancelReason;
    
    /**
     * 派单备注
     */
    @Size(max = 500, message = "派单备注长度不能超过500个字符")
    @TableField("dispatch_remark")
    private String dispatchRemark;
    
    /**
     * 操作人ID
     */
    @TableField("operator_id")
    private Long operatorId;
    
    /**
     * 操作人姓名
     */
    @Size(max = 50, message = "操作人姓名长度不能超过50个字符")
    @TableField("operator_name")
    private String operatorName;
    
    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    
    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    
    /**
     * 创建人
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    private Long createBy;
    
    /**
     * 更新人
     */
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    private Long updateBy;
    
    /**
     * 逻辑删除标识(0-未删除,1-已删除)
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;
}